/*
 * @Date: 2020-02-28 16:28:32 
 * 角色权限表
 */
const mongoose = require('mongoose')

const { Schema } = mongoose


const RoleMenuSchema = new Schema({
                                                              
    role: { type: Schema.Types.ObjectId, ref: 'role', required: true}, //角色
    menu: { type: Schema.Types.ObjectId, ref: 'menu', required: true}, //菜单
    create_at: { type: Date, default: Date.now, index: -1,select: true },
    update_at: { type: Date, default: Date.now ,select: true},
})


RoleMenuSchema.pre('save', function (next) {
    let now = new Date()
    this.update_at = now;
    next()
})




mongoose.model('role_menu', RoleMenuSchema)
module.exports = RoleMenuSchema

